package com.tiancheng.trade.settlement.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 下单场景
 *
 * @author kellen
 * @date 2024/6/8
 */
@Getter
@AllArgsConstructor
public enum OrderSceneEnum {
    app("app", "APP"),
    miniapp("miniapp", "微信小程序"),
    H5("H5", "H5"),
    wxapp("wxapp", "微信公众号"),
    pcweb("pcweb", "PC"),
    face("face", "刷脸"),
    scan("scan", "扫码"),
    union_mini("union_mini", "云闪付小程序");


    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<OrderSceneEnum> found = Arrays.stream(OrderSceneEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return code;
    }

}
